import React, { Component } from 'react'
import "./App.less"
import { withRouter } from "react-router-dom"
import YTKAlert from "@/components/YTKAlert/YTKAlert"
import { connect } from 'react-redux'
import { alertDispatchFn, showYTKAlert } from "@/utils"
import Tabbar from "@/components/Tabbar/Tabbar"
// 如果找不到当前路径,可以使用import {withRouter} from "react-router-dom",然后在componentDidMount中打印this.props,要记得导出export default withRouter(App)
class App extends Component {
    render() {
        
        return (
            <div>
                <YTKAlert></YTKAlert>
                {this.props.children}
                <Tabbar></Tabbar>
             
            </div>
        )
    }
    componentDidMount() {
        // console.log(this.props);
        // 跳转到/home
        if (this.props.location.pathname === "/") {
            this.props.history.push("/home")
        }
    }
    hdClick() {
        console.log(this.props);
        showYTKAlert(this.props,
            "info",
            "抽离出来的内容"
        )


        // // 控制showAlert显示和隐藏
        // this.props.showAlert({
        //     showAlert:true,
        //     alertType:"success",
        //     alertContent:"嘻嘻,臭宝"
        // })

        // // 1.5秒后隐藏
        // setTimeout(()=>{
        //     this.props.hideAlert()
        // },1500)
    }
}

const mapDispatchToProps = dispatch => {
    return {
        ...alertDispatchFn(dispatch)
    }
}



export default connect(null, mapDispatchToProps)(withRouter(App))